package com.moensun.akka.springboot.akka;

import akka.actor.Actor;
import akka.actor.IndirectActorProducer;
import org.springframework.context.ApplicationContext;

/**
 * Created by Bane.Shi.
 * Copyright MoenSun
 * User: Bane.Shi
 * Date: 2017/3/8
 * Time: 15:40
 */
public class SpringActorProducer implements IndirectActorProducer {

	final ApplicationContext applicationContext;
	final String actorBeanName;

	public SpringActorProducer(ApplicationContext applicationContext, String actorBeanName) {
		this.applicationContext = applicationContext;
		this.actorBeanName = actorBeanName;
	}

	public Actor produce() {
		return (Actor) applicationContext.getBean(actorBeanName);
	}

	public Class<? extends Actor> actorClass() {
		return (Class<? extends  Actor>) applicationContext.getType(actorBeanName);
	}
}
